package com.eb.controller;

import com.eb.dto.CommentDto;
import com.eb.result.Result;
import com.eb.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/comment")
@Api(tags = "评论接口")
@Slf4j
@CrossOrigin
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 新建评论
     * @param commentDto
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新建评论")
    public Result addComment(@RequestBody CommentDto commentDto){
        log.info("新建评论: {}", commentDto);
        commentService.add(commentDto);
        return Result.success();
    }
}
